<?php

/*
	Class: DealersDealerTypes

	About: Author
		Rich Joslin

	About: License
		<http://communit.as/docs/license>

	About: See Also
		- <Cts_Db_Table_Abstract>
*/
class DealersDealerTypes extends Cts_Db_Table_Abstract {

	/* Group: Instance Variables */

	/*
		Variable: $_name
	*/
	protected $_name = 'dealers_dealer_types';

	/*
		Variable: $_primary
	*/
	protected $_primary = 'id';

	/* Group: Instance Methods */

	/*
		Function: getAll

		Returns: array of dealers or an empty array
	*/
	function getAll() {
		$tmp_dealer_types = $this->fetchAll();
		if (!is_null($tmp_dealer_types)) {
			return $tmp_dealer_types->toArray();
		} else {
			return array();
		}
	}

	/*
		Function: getOptionsArray

		Arguments:
			first_option - A string that gets placed as the first option with no value.

		Returns: array of dealers or an empty array
	*/
	function getOptionsArray($first_option = null) {
		$tmp_dealer_types = $this->fetchAll();
		if (!is_null($tmp_dealer_types)) {
			$tmp_dealer_types = $tmp_dealer_types->toArray();
			$dealer_types = array();
			if (!is_null($first_option)) {
				$dealer_types[''] = $first_option;
			}
			foreach ($tmp_dealer_types as $type) {
				$dealer_types[$type['id']] = $type['name'];
			}
			return $dealer_types;
		} else {
			return array();
		}
	}

}
